
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>企业微信 · classbro-light-weight-web</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="Gj">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-prism/prism-tomorrow.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../index.css">
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    
    <link rel="prev" href="design.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    引导
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">src</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="framework.html">
            
                <a href="framework.html">
            
                    
                    架构
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="design.html">
            
                <a href="design.html">
            
                    
                    设计模式
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="2.3" data-path="wechat.html">
            
                <a href="wechat.html">
            
                    
                    企业微信
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4" >
            
                <span>
            
                    
                    账户资料
            
                </span>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.4.1" data-path="account/views.html">
            
                <a href="account/views.html">
            
                    
                    视图层
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="2.4.2" data-path="account/vuex.html">
            
                <a href="account/vuex.html">
            
                    
                    MVC 模式
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >企业微信</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="&#x4F01;&#x4E1A;&#x5FAE;&#x4FE1;&#x9274;&#x6743;">&#x4F01;&#x4E1A;&#x5FAE;&#x4FE1;&#x9274;&#x6743;</h1>
<blockquote>
<p>&#x5F00;&#x653E;&#x5E73;&#x53F0;&#x5730;&#x5740; <a href="https://work.weixin.qq.com/api/doc/90001/90144/90545" target="_blank">https://work.weixin.qq.com/api/doc/</a></p>
<p>&#x7B2C;&#x4E09;&#x65B9;&#x9274;&#x6743;&#x64CD;&#x4F5C;&#x57FA;&#x672C;&#x90FD;&#x5927;&#x540C;&#x5C0F;&#x5F02;&#xFF0C;<strong>&#x6548;&#x7387;&#x5E94;&#x7528;</strong>&#x91CC;&#x9762;&#x6CA1;&#x6709;&#x505A;&#x8FC7;&#x591A;&#x4F18;&#x5316;&#xFF0C;&#x4EE3;&#x7801;&#x7528;&#x8D77;&#x6765;&#x4F1A;&#x6BD4;&#x8F83;&#x590D;&#x6742;&#x3002;&#x540E;&#x671F;&#x6539;&#x8FDB;&#x65B9;&#x6848;&#x53EF;&#x4EE5;&#x53C2;&#x8003;<strong>&#x9489;&#x9489;&#x9274;&#x6743;</strong>&#x7684;&#x5305; <a href="https://www.npmjs.com/package/dingtalk-auth&#x3002;" target="_blank">https://www.npmjs.com/package/dingtalk-auth&#x3002;</a></p>
<p>&#x4E0B;&#x9762;&#x53EA;&#x8BB2;&#x89E3;&#x5177;&#x4F53;&#x4F7F;&#x7528;&#x6D41;&#x7A0B;</p>
</blockquote>
<h4 id="&#x5F15;&#x5165;js&#x6587;&#x4EF6;">&#x5F15;&#x5165;JS&#x6587;&#x4EF6;</h4>
<blockquote>
<p>&#x56E0;&#x4E3A;&#x662F;&#x5728;&#x4F01;&#x4E1A;&#x5FAE;&#x4FE1;&#x7684;&#x5BB9;&#x5668;&#x5185;&#x4F7F;&#x7528;&#x5185;&#x7F6E;api&#x529F;&#x80FD;&#xFF0C;&#x6240;&#x4EE5;&#x9700;&#x8981;&#x5728;<strong>index.html</strong>&#x91CC;&#x9762;&#x5168;&#x5C40;&#x5F15;&#x5165;js&#x6587;&#x4EF6;</p>
<p>&#xFF08;&#x652F;&#x6301;https&#xFF09;&#xFF1A;<a href="https://res.wx.qq.com/open/js/jweixin-1.2.0.js" target="_blank">http://res.wx.qq.com/open/js/jweixin-1.2.0.js</a></p>
</blockquote>
<pre class="language-"><code class="lang-html"><span class="token doctype">&lt;!DOCTYPE html&gt;</span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>html</span> <span class="token attr-name">lang</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>en<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>head</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">charset</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>utf-8<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span>
  ...
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>text/javascript<span class="token punctuation">&quot;</span></span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>https://res.wx.qq.com/open/js/jweixin-1.2.0.js<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
  <span class="token comment">&lt;!-- &#x4F01;&#x4E1A;&#x5FAE;&#x4FE1;&#x6388;&#x6743;&#x767B;&#x5F55;&#x4F7F;&#x7528; --&gt;</span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>https://rescdn.qqmail.com/node/ww/wwopenmng/js/sso/wwLogin-1.0.0.js<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>head</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">&gt;</span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">&quot;</span>app<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>body</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>html</span><span class="token punctuation">&gt;</span></span>
</code></pre>
<h4 id="&#x5FAE;&#x4FE1;&#x8C03;&#x7528;&#x5DE5;&#x5177;">&#x5FAE;&#x4FE1;&#x8C03;&#x7528;&#x5DE5;&#x5177;</h4>
<blockquote>
<p>&#x4F01;&#x4E1A;&#x5FAE;&#x4FE1;&#x7528;&#x5230;&#x7684;Api&#x6587;&#x4EF6;&#x548C;&#x9274;&#x6743;&#x64CD;&#x4F5C;&#x6587;&#x4EF6;&#x5177;&#x4F53;&#x90FD;&#x653E;&#x5728;&#x4E86;<strong>src/utils/Wechat/WxUtils.js</strong>&#x6587;&#x4EF6;</p>
<p>&#x4F7F;&#x7528;&#x5982;&#x4E0B; <strong>src/views/customer/material/index.vue</strong></p>
</blockquote>
<pre class="language-"><code class="lang-javascript"><span class="token operator">&lt;</span>script<span class="token operator">&gt;</span>
<span class="token comment">/* &#x5BA2;&#x6237;&#x8D44;&#x6599; */</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> Customer <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;@/store/dispatch/index&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> Storage <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;@/utils/Enum/index&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> WeChatEnv <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;@/utils/Enum/WeChat&quot;</span><span class="token punctuation">;</span>
<span class="token keyword">import</span> <span class="token punctuation">{</span> getWeChatEnv <span class="token punctuation">}</span> <span class="token keyword">from</span> <span class="token string">&quot;@/utils/Wechat/WxUtils&quot;</span><span class="token punctuation">;</span>

<span class="token keyword">export</span> <span class="token keyword">default</span> <span class="token punctuation">{</span>
  methods<span class="token operator">:</span> <span class="token punctuation">{</span>
    <span class="token keyword">async</span> <span class="token function">init</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token keyword">await</span> <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">validateEnv</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span>bodyShow <span class="token operator">=</span> <span class="token boolean">true</span><span class="token punctuation">;</span>
        <span class="token keyword">await</span> Customer<span class="token punctuation">.</span>Material<span class="token punctuation">.</span><span class="token function">getUserDetail</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        Customer<span class="token punctuation">.</span>Material<span class="token punctuation">.</span><span class="token function">initList</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token comment">/* &#x8D26;&#x6237;&#x4FE1;&#x606F;&#x5217;&#x8868; */</span>
        Customer<span class="token punctuation">.</span>Account<span class="token punctuation">.</span><span class="token function">getAccounts</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
        <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">$message</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
          duration<span class="token operator">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
          message<span class="token operator">:</span> <span class="token string">&quot;&#x8BF7;&#x524D;&#x5F80;&#x4E0E;&#x5BA2;&#x6237;&#x7684;&#x804A;&#x5929;&#x7A97;&#x53E3;&#x53F3;&#x4FA7;&#x5DE5;&#x5177;&#x680F;&#x67E5;&#x770B;&quot;</span><span class="token punctuation">,</span>
          type<span class="token operator">:</span> <span class="token string">&quot;warning&quot;</span>
        <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token comment">/**&#x6821;&#x9A8C;&#x5F53;&#x524D;&#x5165;&#x53E3;&#x73AF;&#x5883; */</span>
    <span class="token keyword">async</span> <span class="token function">validateEnv</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">const</span> _env <span class="token operator">=</span> <span class="token keyword">await</span> <span class="token function">getWeChatEnv</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token string">&quot;&#x5F53;&#x524D;&#x5165;&#x53E3;&#x73AF;&#x5883;:&quot;</span><span class="token punctuation">,</span> _env<span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token keyword">return</span> _env <span class="token operator">!=</span> WeChatEnv<span class="token punctuation">.</span><span class="token constant">NORMAL</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span><span class="token punctuation">,</span>
    <span class="token comment">/**
     * &#x5B9A;&#x65F6;&#x5668;&#x505A;&#x8C03;&#x5EA6;&#xFF0C;&#x5224;&#x65AD;&#x5F53;&#x524D;&#x4F01;&#x4E1A;&#x5FAE;&#x4FE1;&#x662F;&#x5426;&#x5DF2;&#x7ECF;&#x9274;&#x6743;&#x901A;&#x8FC7;
     */</span>
    <span class="token function">dispatch</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token keyword">this</span><span class="token punctuation">.</span>intervalId <span class="token operator">=</span> <span class="token function">setInterval</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
        <span class="token keyword">const</span> config <span class="token operator">=</span> localStorage<span class="token punctuation">.</span><span class="token function">getItem</span><span class="token punctuation">(</span>Storage<span class="token punctuation">.</span><span class="token constant">AGENT_CONFIG</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span>config<span class="token punctuation">)</span> <span class="token function">clearInterval</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>intervalId<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token keyword">else</span> <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">+</span>config <span class="token operator">===</span> <span class="token number">1</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
          <span class="token comment">//&#x9274;&#x6743;&#x901A;&#x8FC7;&#x540E;&#xFF0C;&#x6E05;&#x9664;&#x5B9A;&#x65F6;&#x5668;</span>
          <span class="token function">clearInterval</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>intervalId<span class="token punctuation">)</span><span class="token punctuation">;</span>
          <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">init</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span> <span class="token number">500</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token comment">//&#x9700;&#x8981;&#x5728;&#x9875;&#x9762;&#x52A0;&#x8F7D;&#x5B8C;&#x6210;&#x540E;&#x505A;&#x8C03;&#x5EA6;</span>
  <span class="token function">mounted</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">this</span><span class="token punctuation">.</span><span class="token function">dispatch</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>
<span class="token operator">&lt;</span><span class="token operator">/</span>script<span class="token operator">&gt;</span>
</code></pre>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="design.html" class="navigation navigation-prev navigation-unique" aria-label="Previous page: 设计模式">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"企业微信","level":"2.3","depth":1,"next":{"title":"账户资料","level":"2.4","depth":1,"ref":"","articles":[{"title":"视图层","level":"2.4.1","depth":2,"path":"src/account/views.md","ref":"src/account/views.md","articles":[]},{"title":"MVC 模式","level":"2.4.2","depth":2,"path":"src/account/vuex.md","ref":"src/account/vuex.md","articles":[]}]},"previous":{"title":"设计模式","level":"2.2","depth":1,"path":"src/design.md","ref":"src/design.md","articles":[]},"dir":"ltr"},"config":{"plugins":["expandable-chapters","-lunr","-search","search-pro","-highlight","prism"],"styles":{"website":"index.css"},"pluginsConfig":{"prism":{"css":["prismjs/themes/prism-tomorrow.css"]},"expandable-chapters":{},"search-pro":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"theme":"default","author":"Gj","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"classbro-light-weight-web","language":"zh-hans","gitbook":"3.2.3","description":"效率应用"},"file":{"path":"src/wechat.md","mtime":"2020-07-28T04:48:39.603Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2020-07-28T06:09:20.949Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-expandable-chapters/expandable-chapters.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

